package com.itheima.algorithm.binarysearchtree;

import com.itheima.algorithm.binarytree.TreeNode;

import java.util.LinkedList;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @author: TylerZhong
 * @description:
 */
public class E04Leetcode938 {
    private int sum = 0;
    public int rangeSumBST(TreeNode node, long min,long max) {
        if (node == null) {
            return 0;
        }
        if (node.val < min) {
            return rangeSumBST(node.right, min, max);
        }
        if (node.val > max) {
            return rangeSumBST(node.left, min, max);
        }
        return node.val + rangeSumBST(node.left, min, max)+rangeSumBST(node.right, min, max);
    }

    // 解法2 上下限递归
    public int isValidBST(TreeNode node) {

        return 0;
    }
}
